﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;

namespace Treasures
{
    public class LabelAnimation
    {
        #region fields and props

        public Point Location { get; private set; }
        public string Text { get; private set; }
        public int Opacity { get; private set; }

        #endregion

        #region ctors

        public LabelAnimation(Point p, int op, string text)
        {
            this.Location = p;
            this.Opacity = op;
            this.Text = text;
        }

        #endregion

        #region public methods

        public void PlusPointsAnim(int step, int sleep)
        {
            int N = 75;
            int threshold = 50;
            for (int cnt = 0; cnt < N; cnt++)
            {
                if (N > threshold || this.Opacity > 0)
                {
                    this.Opacity -= (int)(100f / (float)(N - threshold));
                }
                if (this.Opacity < 0)
                {
                    this.Opacity = 0;
                }
                this.Location = new Point(this.Location.X, this.Location.Y - step);
                Thread.Sleep(sleep);
            }
        }

        #endregion
    }
}
